package org.gten.gegedexin.controller;

import com.alibaba.fastjson.JSONArray;
import org.gten.gegedexin.Data.QueryInformation;
import org.gten.gegedexin.service.ConditionalQuery;
import org.gten.gegedexin.service.QueryMail;
import org.gten.gegedexin.service.ReadMailList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class QueryController {
    @Autowired
    QueryMail queryMail;
    @Autowired
    ReadMailList readMailList;
    @Autowired
    ConditionalQuery conditionalQuery;

    @RequestMapping("/query")
    @CrossOrigin
    public JSONArray query(QueryInformation queryInf){
        readMailList.readList(readMailList.getUser());
        conditionalQuery.queryWithConditional(queryInf);
        return conditionalQuery.returnPage(queryInf.getPage());
    }
//
//    @RequestMapping("/querySender")
//    public int querySender(String key){
//        queryMail.queryWithSender(readMailList.getworking(),key);
//        return queryMail.returnPage();
//    }
//
//    @RequestMapping("/queryTitle")
//    public int queryTitle(String key){
//        queryMail.queryWithTitle(readMailList.getworking(),key);
//        return queryMail.returnPage();
//    }
//
//    @RequestMapping("/queryRead")
//    public int queryRead(){
//        readMailList.settingWorking(1);
//        queryMail.setList(readMailList.getworking());
//        return queryMail.returnPage();
//    }
//
//    @RequestMapping("/queryNotRead")
//    public int queryNotRead(){
//        readMailList.settingWorking(0);
//        queryMail.setList(readMailList.getworking());
//        return queryMail.returnPage();
//    }
//
//    @RequestMapping("/queryCollect")
//    public int queryCollect(){
//        readMailList.settingWorking(3);
//        queryMail.setList(readMailList.getworking());
//        return queryMail.returnPage();
//    }
//
//    @RequestMapping("/queryList")
//    @ResponseBody
//    @CrossOrigin
//    public JSONArray queryList(int page){
//        return queryMail.queryPage(page);
//    }
}
